package com.cloudcc.mobile.adapter;

import android.content.Context;

import com.cloudcc.cloudframe.adapter.CommonAdapter;
import com.cloudcc.cloudframe.adapter.NewCommonAdapter;
import com.cloudcc.cloudframe.adapter.ViewHolder;
import com.cloudcc.mobile.R;
import com.cloudcc.mobile.entity.map.NearByMapInfo;

/**
 * Created by lin on 2017/5/10.
 */

public class NearByListAdapter extends NewCommonAdapter {

    public NearByListAdapter(Context mContext) {
        super(mContext);
    }

    @Override
    public void convert(ViewHolder holder, Object o, int position) {
        NearByMapInfo.NearByMapInfo2 nearByMapInfo2 = (NearByMapInfo.NearByMapInfo2) o;
        holder.setText(R.id.near_by_list_item_name , (position+1)+"."+nearByMapInfo2.getName());
        String distanceNow = String.format(mContext.getResources().getString(R.string.near_by_now_distance), nearByMapInfo2.getDistance());
        holder.setText(R.id.near_by_list_item_long , (nearByMapInfo2.getDistance() == null ? mContext.getString(R.string.null_now) : distanceNow));
        holder.setText(R.id.near_by_list_item_address , nearByMapInfo2.getAddress());
    }


    @Override
    public int getLayoutId() {
        return R.layout.near_by_list_item;
    }

}
